package com.company.practice;

/**
 * @description: https://blog.csdn.net/soonfly/article/details/70147205  关于str的相关知识
 * @author: ruoan
 * @date: 2021/1/5 19:28
 */
public class StringDemo {
    public static void main(String[] args) {
        String s1 = "abc";
        String s2 = "a";
        String s3 = "bc";
        String s4 = s2 + s3;
        System.out.println(s1 == s4);  //false


        String s11 = "abc";
        final String s21 = "a";
        final String s31 = "bc";
        String s41 = s21 + s31;
        System.out.println(s11 == s41);  //true

        System.out.println("----------------------");



        String str2 = new String("str")+new String("01");
        str2.intern();
        String str1 = "str01";
        System.out.println(str2==str1);  // true


        String str22 = new String("str")+new String("01");
        String str12 = "str01";
        str22.intern();
        System.out.println(str22==str12);  // false





    }
}
